package com.example.micro.jvm.server.reflect;

public class ReflectClassGetTest {

    public static void main(String[] args) {
        Person student = new Student();
        Class studentClass1 = student.getClass();
        //通过类名会更高效
        Class studentClass2 = Student.class;

        System.out.println(studentClass1.hashCode() + " " + studentClass2.hashCode());

        //获得父类类型
        Class personClass = studentClass1.getSuperclass();

    }

}

class Person {
    public String name;
}

class Student extends Person {
    public Student() {
        this.name = "student";
    }
}

class Teacher extends Person {
    public Teacher() {
        this.name = "teacher";
    }
}